using Circus.CodeEditor;
using System;
using System.Drawing;
namespace Circus.Syntax
{
	[Serializable]
	public class SyntaxError :  ICloneable
	{
		private string name = string.Empty;
		private string description = string.Empty;
		private Range range = new Range(0, 0, 0, 0);
		private SyntaxErrorType errorType = SyntaxErrorType.Error;
		public virtual string Name
		{
			get
			{
				return this.name;
			}
			set
			{
				if (this.name != value)
				{
					this.name = value;
					this.OnNameChanged();
				}
			}
		}
		public virtual string Description
		{
			get
			{
				return this.description;
			}
			set
			{
				if (this.description != value)
				{
					this.description = value;
					this.OnDescriptionChanged();
				}
			}
		}
		public virtual Point Position
		{
			get
			{
				return this.range.StartPoint;
			}
			set
			{
				if (this.range.StartPoint != value)
				{
					this.range.StartPoint = value;
					this.range.EndPoint = new Point(value.X + this.name.Length, value.Y);
					this.OnPositionChanged();
				}
			}
		}
		public virtual Size Size
		{
			get
			{
				return new Size(this.range.EndPoint.X - this.range.StartPoint.X, this.range.EndPoint.Y - this.range.StartPoint.Y);
			}
			set
			{
				this.range.EndPoint = new Point(this.range.StartPoint.X + value.Width, this.range.StartPoint.Y + value.Height);
				this.OnSizeChanged();
			}
		}
		public virtual Range Range
		{
			get
			{
				return this.range;
			}
			set
			{
				if (this.range != value)
				{
					this.range = value;
					this.OnRangeChanged();
				}
			}
		}
		public virtual SyntaxErrorType ErrorType
		{
			get
			{
				return this.errorType;
			}
			set
			{
				if (this.errorType != value)
				{
					this.errorType = value;
					this.OnErrorTypeChanged();
				}
			}
		}
		protected virtual void OnNameChanged()
		{
		}
		protected virtual void OnDescriptionChanged()
		{
		}
		protected virtual void OnPositionChanged()
		{
		}
		protected virtual void OnSizeChanged()
		{
		}
		protected virtual void OnRangeChanged()
		{
		}
		protected virtual void OnErrorTypeChanged()
		{
		}
		public SyntaxError()
		{
		}
		public SyntaxError(Point position)
		{
			this.range.StartPoint = position;
			this.range.EndPoint = position;
		}
		public SyntaxError(Point position, string name, string description) : this(position)
		{
			this.name = name;
			this.description = description;
			this.range.EndPoint = new Point(position.X + name.Length, position.Y);
		}
		public override string ToString()
		{
			return (this.name != string.Empty) ? this.name : base.ToString();
		}
		public virtual object Clone()
		{
			return new SyntaxError
			{
				Name = this.name,
				Description = this.description,
				Range = (Range)this.range.Clone(),
				ErrorType = this.errorType
			};
		}
	}
}
